﻿function Get-TSMDeviceClass {    
    <#
        .SYNOPSIS
            Get TSM device classes
                    
        .DESCRIPTION
            The Get-TSMDeviceClass returns device classes

        .PARAMETER DeviceClass
            The device class to search

        .PARAMETER Type
            The type to search

        .EXAMPLE
            Get-TSMDeviceClass

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/03/2015

    #>
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0)]
        $DeviceClass
    )
    
    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "DEVCLASS_NAME"; "Operator" = "LIKE"; "Value" = $DeviceClass }

    $query = Format-TSMQuery -Table "DEVCLASSES" -Where $whereProps -OrderBy "DEVCLASS_NAME"
    $result = Invoke-TSMCommand -Command $query
    
    $defaultDisplaySet = 'DeviceClassName','DeviceAccessStrategy','StoragePoolCount','DeviceType','Format','CapacityMB','MountLimit'
    $typeDefinitions = @{
                        "CAPACITY"       = [Int64]
                        "LAST_UPDATE"    = [DateTime]
                        "MOUNTRETENTION" = [Int32]
                        "MOUNTWAIT"      = [Int32]
                        "PRIMARYALLOC"   = [Int32]
                        "RETENCTION"     = [Int32]
                        "RETRYINTERVAL"  = [Int32]
                        "RETRYPERIOD"    = [Int32]
                        "SCALECAPACITY"  = [Int32]
                        "SECONDARYALLOC" = [Int32]
                        "SHARED"         = [bool]
                        "STGPOOL_COUNT"  = [Int32]
                        "WORM"           = [bool]
                        }
    $friendlyNames = @{
                      "ACCESS_STRATEGY"  = "DeviceAccessStrategy"
                      "CAPACITY"         = "CapacityMB"
                      "DEVCLASS_NAME"    = "DeviceClassName"
                      "DEVTYPE"          = "DeviceType"
                      "DIRECTORY"        = "Directory"
                      "DRIVE_ENCRYPTION" = "DriveEncryption"
                      "EXPIRATION"       = "Expiration"
                      "FORMAT"           = "Format"
                      "HLADDRESS"        = "HighLevelAddress"
                      "LAST_UPDATE"      = "LastUpdate"
                      "LAST_UPDATE_BY"   = "LastUpdateBy"
                      "LBPROTECT"        = "LogicalBlockProtection"     
                      "LIBRARY_NAME"     = "LibraryName"
                      "MINCAPACITY"      = "MinimumCapacity"
                      "MOUNTLIMIT"       = "MountLimit"
                      "MOUNTRETENTION"   = "MountRetention"
                      "MOUNTWAIT"        = "MountWait"
                      "PREFIX"           = "Prefix"
                      "PRIMARYALLOC"     = "PrimaryAllocationMB"
                      "PROTECTION"       = "Protection"
                      "RETENTION"        = "Retention"
                      "RETRYINTERVAL"    = "RetryInterval"
                      "RETRYPERIOD"      = "RetryPeriod"
                      "SCALECAPACITY"    = "ScaleCapacity"
                      "SECONDARYALLOC"   = "SecondaryAllocationMB"
                      "SERVERNAME"       = "ServerName"
                      "SHARED"           = "Shared"
                      "STGPOOL_COUNT"    = "StoragePoolCount"
                      "UNIT"             = "Unit"
                      }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet -FriendlyNames $friendlyNames
}